import { DayReport} from "../sql/domin";
import {arrayToMap, deleteSql, insertSql, objectToMap, selectSql, updateSql} from "../util/sqlUtils";

export class ReportMapper{
    public static insertReport(dayReports:DayReport[]){
        return insertSql('day_report',arrayToMap(dayReports))
    }

    public static deleteReportBefore30Day(){
        return deleteSql('day_report',
            `where date('now','-30 day') >= date(createTime)`)
    }

    public static updateReport(dayReport:DayReport){
        return updateSql('day_report',objectToMap(dayReport),
            'where id = '+dayReport.id)
    }

    public static selectReportList(){
        return selectSql('day_report')
    }

    public static selectReportById(id:number){
        return selectSql('day_report',new Map([
            ['id',id]
        ]))
    }
}
